MyID=$(wget -q -O - http://169.254.169.254/latest/meta-data/instance-id)
IP=$(cat conf/servers.conf | grep $MyID | awk {'print $2'})
N=$(cat conf/servers.conf | grep $MyID | awk {'print $3'})
PrisMWVersion=$(cat conf/servers.conf | grep $MyID | awk {'print $4'})
TileFile=$(cat conf/servers.conf | grep $MyID | awk {'print $5'})
SeedFile=$(cat conf/servers.conf | grep $MyID | awk {'print $6'})
OutFileEx=$(cat conf/servers.conf | grep $MyID | awk {'print $7'})
JobID=$(cat conf/servers.conf | grep $MyID | awk {'print $8'})

Date=$(date '+%Y-%m-%d-%H-%M-%S')

SeedFileModified=$(echo $SeedFile | tr '/' '_')
OutPutFileName="file-$SeedFileModified-date-$Date-num-$N-$OutFileEx"


flag=1
Size=$(./getSizeOfFile.sh *.out)
echo "ouChecker: size is $Size"
Seconds=0
Delta=10
Threshold=36000	
#Count=$(find . -type f -maxdepth 1 -name '?*.out' | wc -c)
while [ $flag -eq 1 ]
do
	Size=$(./getSizeOfFile.sh *.out)
	if [ $Size -lt 1 ]; then
		Seconds=$((Seconds+Delta))
		echo "$Seconds: No"
	else
		echo "$Seconds: Yes"
		exit
	fi
	if [ $Seconds -ge $Threshold ]; then
		echo "This compuation has taken too long"
		rm *.out
		echo "$Seconds: It took very long so I decided to terminate it" >> $OutPutFileName
		exit
	fi
	sleep $Delta
done
exit


